//  前端gis订阅类
class EventBus {
    private eventTarget: EventTarget;
  
    constructor() {
      this.eventTarget = new EventTarget();
    }
  
    // 订阅事件
    public subscribe(eventName: string, callback: EventListener) {
      this.eventTarget.addEventListener(eventName, callback);
    }
  
    // 取消订阅事件
    public unsubscribe(eventName: string, callback: EventListener) {
      this.eventTarget.removeEventListener(eventName, callback);
    }
  
    // 自定义事件分发方法
    public dispatchEvent(eventName: string, detail: any) {
      const event = new CustomEvent(eventName, { detail });
      this.eventTarget.dispatchEvent(event);
    }
  }
  
  export const eventBus = new EventBus();